package com.glory.wxmemsicpda.adapter

import androidx.fragment.app.FragmentManager
import com.chad.library.adapter.base.BaseQuickAdapter
import com.glory.wxmemsicpda.R
import com.glory.wxmemsicpda.base.DataBindBaseViewHolder
import com.glory.wxmemsicpda.bean.FGMaterialBean
import com.glory.wxmemsicpda.databinding.AdapterPgMaterialsBinding
import com.pda.platform.ui.ui_pdaplatform.callback.FreeUI_CommonCallback
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_DialogUtils

class FGMaterialAdapter(data: List<FGMaterialBean.MLOTDTO?>?
                        ,var fragment: FragmentManager):
    BaseQuickAdapter<FGMaterialBean.MLOTDTO?, DataBindBaseViewHolder>(
        R.layout.adapter_pg_materials,data as MutableList<FGMaterialBean.MLOTDTO?>) {
    override fun convert(
        helper: DataBindBaseViewHolder,
        item: FGMaterialBean.MLOTDTO?
    ) {
        val binding: AdapterPgMaterialsBinding = helper.getDataBinding() as AdapterPgMaterialsBinding
        binding.materialBean = item
        binding.noNum.text = (helper.adapterPosition + 1).toString()
        if (item!!.mainqty==null){
            binding.mainQTY.text = "0"
        }else{
            binding.mainQTY.text = item!!.mainqty.toString()
        }
        binding.tvDel.setOnClickListener {
            FreeApi_DialogUtils.getConfirmAndCancelDialog(
                helper.itemView.context,
                "是否确认删除?",
                FreeUI_CommonCallback { //                    qtyNum.remove(helper.getPosition());
                    remove(helper.position)
                    notifyDataSetChanged()
                },
                FreeUI_CommonCallback {}).show(fragment, "DELETE_DIALOG")
        }
    }
}